package com.ydc.ln.tutorial.gui.test.comp;

import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * 选择组件
 * 
 * @author ydc
 * @date 上午1:22:01 2013-5-18
 */
public class ChoiceCompFrame extends Frame {

    /**
     * @Fields serialVersionUID 
     */ 
    private static final long serialVersionUID = -6368628342630749081L;
    
    public static void main(String[] args) {
        final int width = 200;
        final int height = 200;
        final int loX = 10;
        final int loH = 210;
        int loY = 30;
        
        
        ChoiceCompFrame ccf = new ChoiceCompFrame("Chocie Component Frame");
        ccf.setSize(width, 700);
        ccf.setBackground(Color.WHITE);
        ccf.setLocation(80, 80);
        ccf.setLayout(null);
        
        // p1 > checkbox
        Panel p1 = new Panel();
        p1.setSize(width, height);
        p1.setBackground(Color.CYAN);
        p1.setLocation(loX, loY);
        p1.add(new Checkbox("one", true));
        p1.add(new Checkbox("two", false));
        p1.add(new Checkbox("three", false));
        
        // p2 > CheckboxGroup
        loY+=loH;
        Panel p2 = new Panel();
        p2.setBackground(Color.CYAN);
        p2.setSize(width, height);
        p2.setLocation(loX, loY);
        CheckboxGroup cbg = new CheckboxGroup();
        p2.add(new Checkbox("one", cbg, true));
        p2.add(new Checkbox("two", cbg, false));
        p2.add(new Checkbox("three", cbg, false));
        
        // p3 > Choice
        loY+=loH;
        Panel p3 = new Panel();
        p3.setBackground(Color.CYAN);
        p3.setSize(width, height);
        p3.setLocation(loX, loY);
        Choice ch = new Choice();
        p3.add(ch);
        ch.add("Green");
        ch.add("Blue");
        ch.add("Red");
        
        ccf.add(p1);
        ccf.add(p2);
        ccf.add(p3);
        ccf.setVisible(true);
    }
    
    public ChoiceCompFrame(String title) {
        super(title);
        this.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
               System.exit(0);
           }
        });
    }
}
